<?php

/**
 * Description of components
 *
 * @author jahid
 */
class dataComponents extends sfComponents {

    /**
     * Observation depth detail (species) form
     */
    public function executeSpeciesForm(){
        $this->obsDetailForm = new ObservationdepthdetailForm();
        $this->obsDepthForm =  new ObservationdepthForm();
        $this->speciesForm = new SpeciesForm();
        $this->unitForm = new UnitForm();
    }

    /**
     * Observation depth detail (species) list
     * @param sfWebRequest $request
     */
    public function executeSpeciesList(sfWebRequest $request){
        $this->pager = new sfDoctrinePager('Observationdepthdetail', 10);
        $this->pager->setQuery(Doctrine::getTable('observationdepthdetail')
                ->getSpeciesDescriptionQuery('observationdepthid = ?', empty($this->currentDepth) ? '' : $this->currentDepth->id));
        $this->pager->setPage($this->page);
        $this->pager->init();
    }

    /**
     * Observation depth list
     * @param sfWebRequest $request
     */
    public function executeDepthList($request) {
        $query = Doctrine::getTable('Observationdepth')->createQuery('od')
                            ->where('observationid = ?', $this->observationId)
                            ->orderBy('observationdepth');
        $this->depths = $query->execute();
        
    }

    /**
     * Observation depth attribute form
     */
    public function executeAttributeForm() {
        $this->obsAttributeForm = new ObservationdepthattributeForm();
        $this->obsDepthForm =  new ObservationdepthForm();
        $this->attributeForm = new AttributeForm();
        $this->unitForm = new UnitForm();
    }

    /**
     * Observation depth attribute list
     */
    public function executeAttributeList() {
        $this->pager = new sfDoctrinePager('Observationdepthattribute', 10);
        $this->pager->setQuery(Doctrine::getTable('observationdepthattribute')
                ->getAttributeListQuery('observationdepthid = ?', empty($this->currentDepth) ? '' : $this->currentDepth->id));
        $this->pager->setPage($this->page);
        $this->pager->init();
    }
}
?>
